import cv2
import numpy as np

img = cv2.imread("./img/color_recognize3.png")
h, w, _ = img.shape
img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)

mask1 = cv2.inRange(img_hsv, (156, 43, 46), (180, 255, 255))
mask2 = cv2.inRange(img_hsv, (0, 43, 46), (10, 255, 255))
mask = cv2.bitwise_or(mask1, mask2)

# cv2.imshow("red_mask", mask)
mask = cv2.merge([mask, mask, mask])
result = cv2.bitwise_and(img, mask)
a = result[:, :, 0]
# a = np.where((10 >= a) & (a > 0), 35, a)
# a = np.where((180 >= a) & (a >= 156), 77, a)
# result[:, :, 0] = a
a = a / 180 * 77
result[:, :, 0] = a

# result = cv2.bitwise_or(img,mask)

result = cv2.cvtColor(result,cv2.COLOR_HSV2BGR)
cv2.imshow("result", result)
cv2.waitKey(0)
